function [X, Y, U, V, B] = model(et, s)
    % sx = [1 2 4 6 7];
    sx = [1 4 8 9 11];
    % sx = [1 4 5 8 11];
    sy = 1;

    % format sections
    if isrow(s)
        s = s';
    end
    s = repmat(s, 1, 2);
    for i = 1 : (size(s, 1) - 1)
        s(i, 2) = s(i + 1, 1) - 1;
    end
    s(end, 2) = et.m;

    X = et.Temp(:, sx);
    Y = et.Eddy(:, sy);
    U = zeros(size(s, 1) - 1, numel(sx));
    V = zeros(size(s, 1) - 1, 1);
    B = [];
    for i = 1 : size(s, 1)
        st = s(i, 1);
        ed = s(i, 2);

        x = X(st:ed, :);
        y = Y(st:ed, :);

        if isempty(B)
            B = regress(y, [ones(numel(y), 1) x]);
        else
            d = y - [ones(numel(y), 1) x] * B;

            D = [];
            R = inf;
            for v = min(d):0.1:max(d)
                Y(st:ed, 1) = y - v;

                [b, ~, r, ~, ~] = regress(Y(1:ed), [ones(ed, 1) X(1:ed, :)]);
                t = max(abs(r));

                if t < R
                    R = t;
                    D = v;
                    B = b;
                end
            end

            Y(st:ed, 1) = y - D;

            U(i - 1, :) = X(st, :) - X(st-1, :);
            V(i - 1, :) = Y(st, :) - Y(st-1, :) + D;
        end
    end

    % V = U * B(2:end) + V;
end
